OpenRoads Designer CONNECT Edition SDK Help

Browse all levels

The below code snippet shows browsing all the levels and printing the names of used levels in current DGN.


 public void BrowseAllLevels()
        {
            //Get Active Dgn Model
            DgnModel model = Session.Instance.GetActiveDgnModel();

            //Get levels information from current DGN model
            FileLevelCache fileLevelCache = model.GetFileLevelCache();

            //Get collection of all levels
            LevelHandleCollection levelHandles = fileLevelCache.GetHandles();

            foreach (LevelHandle lh in levelHandles)
            {
                //Check if level is used in current DGN file
                bool isUsed = fileLevelCache.IsLevelUsedInFile(lh.LevelId);
                if (isUsed)
                {
                    //Print used levels name
                    System.Diagnostics.Debug.Print("Level Used: " + lh.Name);
                }
            }
        }

The below image shows list of used levels in current DGN file from Visual studio Output window

Output